
import React, { useEffect, useState, useRef } from 'react';
import { Edge } from '@antv/x6';
type ModalType = 'edit' | 'add';
export default function useModal() {
  const [modalType, setModalType] = useState<ModalType>('add');
  const [open, setOpen] = useState<boolean>(false);
  const [form, setForm] = useState<any>({});
  const handleCreate = (edge: Edge,modalType:ModalType = 'add') => {
    setModalType(modalType);
    setOpen(true);
    setForm(edge);
  };
  const updataNodeModal = (data: any) => {
    setModalType('edit');
    setOpen(true);
    setForm(data);
  };
  return {
    open,
    form,
    setForm,
    setOpen,
    modalType,
    handleCreate,
    updataNodeModal
  };
}
export type {
  ModalType,
}